//
//  JZHomeShopCell.m
//  NuoMi
//
//  Created by liangyi on 15/12/4.
//  Copyright © 2015年 liangyi. All rights reserved.
//

#import "JZHomeShopCell.h"

@implementation JZHomeShopCell
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.shopImageView = [[UIImageView alloc]init];
        self.shopNameLabel = [[UILabel alloc]init];
        self.shopDesLabel = [[UILabel alloc]init];
        self.newpriceLabel = [[UILabel alloc]init];
        self.oldPriceLabel = [[UILabel alloc]init];
        self.distanceLabel = [[UILabel alloc]init];
        self.scoreLabel = [[UILabel alloc]init];
        
    }
    
    return self;
    
    
}

- (void)layoutSubviews

{
    [super layoutSubviews];
    
    self.shopImageView.frame = CGRectMake(10, 15, 80, 70);
    [self.contentView addSubview:self.shopImageView];
    
    _shopNameLabel.frame = CGRectMake(100, 12, 200, 18);
    [self.contentView addSubview:self.shopNameLabel];
    self.shopNameLabel.font = [UIFont systemFontOfSize:15];
    
    _shopDesLabel.frame =CGRectMake(100, 40, 200, 15);
    [self.contentView addSubview:self.shopDesLabel];
    self.shopDesLabel.font = [UIFont systemFontOfSize:12];
    self.shopDesLabel.textColor= [UIColor grayColor];
    
    _newpriceLabel.frame = CGRectMake(100, 63, 61, 18);
    [self.contentView addSubview:self.newpriceLabel];
    self.newpriceLabel.font = [UIFont systemFontOfSize:14];
    self.newpriceLabel.textColor = [UIColor redColor];
    
    _oldPriceLabel.frame = CGRectMake(160, 63, 61, 18);
    [self.contentView addSubview:self.oldPriceLabel];
    self.oldPriceLabel.font = [UIFont systemFontOfSize:12];
    self.oldPriceLabel.textColor = [UIColor redColor];
    
    _distanceLabel.frame = CGRectMake(265, 12, 41, 18);
    [self.contentView addSubview:self.distanceLabel];
    self.distanceLabel.font = [UIFont systemFontOfSize:12];
    
}


-(void)setShopM:(JZShopTuanModel *)shopM {
    
    _shopM = shopM;
    
    
    
    

    _scoreLabel.frame = CGRectMake(265, 66, 41, 18);
    [self.contentView addSubview:self.scoreLabel];
    self.scoreLabel.font = [UIFont systemFontOfSize:12];
    self.scoreLabel.textColor = [UIColor orangeColor];
    NSRange range = [shopM.image rangeOfString:@"src="];
    if (range.location != NSNotFound) {
        NSString *subStr = [shopM.image substringFromIndex:range.location+range.length];
        subStr = [subStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [self.shopImageView sd_setImageWithURL:[NSURL URLWithString:subStr] placeholderImage:[UIImage imageNamed:@"ugc_photo"]];
//        NSLog(@"%ld", self.shopImageView.tag);
        
    }
    //    NSString *str = [shopM.image stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    //    [self.shopImageView sd_setImageWithURL:[NSURL URLWithString:shopM.image] placeholderImage:[UIImage imageNamed:@"ugc_photo"]];
    
    self.shopNameLabel.text = shopM.brand_name;
    self.shopDesLabel.text = shopM.short_title;
    self.distanceLabel.text = shopM.distance;
    self.newpriceLabel.text = [NSString stringWithFormat:@"￥%ld",[shopM.groupon_price integerValue]/100];
    self.scoreLabel.text = shopM.score_desc;
    
    NSString *oldStr = [NSString stringWithFormat:@"%ld",[shopM.market_price integerValue]/100];
    //中划线
    NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
    //下划线
    //        NSDictionary *attribtDic = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
    NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:oldStr attributes:attribtDic];
    self.oldPriceLabel.attributedText = attribtStr;
    
    
}


@end
